package com.qiaoyanqing.ximalaya.downloadmodule.download_fragment.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.qiaoyanqing.ximalaya.R;
import com.qiaoyanqing.ximalaya.downloadmodule.download_fragment.bean.Hot_list;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2016/12/12.
 */

public class DownLoad_Hot_Adapter extends RecyclerView.Adapter<DownLoad_Hot_Adapter.MyViewHolder>{
    private Context context;
    private List<Hot_list>list;

    public DownLoad_Hot_Adapter(Context context, List<Hot_list> list ) {

        this.context = context;
        this.list = list;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
       View view = LayoutInflater.from(context).inflate(R.layout.download_hot_item,parent,false);
        MyViewHolder holder = new MyViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
            holder.title_tv.setText(list.get(position).getTitle());
        holder.intro_tv.setText(list.get(position).getIntro());
        holder.tracks_tv.setText(String.valueOf(list.get(position).getTracks()));
        holder.playsCounts_tv.setText(list.get(position).getPlaysCounts());
        Log.d("555","------"+list.get(position).getCoverSmall());
        if (!list.get(position).getCoverSmall().equals("")){

        Picasso.with(context).load(list.get(position).getCoverSmall()).into(holder.imageView);
        }
    }

    @Override
    public int getItemCount() {
        return list.size();
    }


    static class MyViewHolder extends RecyclerView.ViewHolder{
        private ImageView imageView;
        private TextView title_tv,intro_tv,playsCounts_tv,tracks_tv;

        public MyViewHolder(View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.broadcase_iv);
            title_tv = (TextView) itemView.findViewById(R.id.titles);
            intro_tv = (TextView) itemView.findViewById(R.id.intro);
            playsCounts_tv = (TextView) itemView.findViewById(R.id.playsCounts);
            tracks_tv = (TextView) itemView.findViewById(R.id.tracks_tv);
        }
    }
}
